const router = require('express').Router();
const jwt =require('jsonwebtoken')
const db = require('../config/db')
var User = require('../config/userSql')

router.post('/login',async (req, res) => {

    let { username, password } =await req.body

    let sql = 'select * from register where username=? and password=? '

    let data = [username, password]
    db.query(sql , data , results => { 
        if(results.length > 0){
        res.send({
        status: 200,
        username:username,
        password:password,
        message: '登录成功',
            token :jwt.sign({
            username:"username",
            password:"password"
        },"5455",)})
        }else {
        res.send({
        status: 400,
        message: '用户名或者密码错误',
        })
    }
})
})

module.exports = router